package com.Controller;

import com.Service.UserService;
import com.domain.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class login {
    /*ApplicationContext ac  = new ClassPathXmlApplicationContext("applicationContext.xml");
   *//* ApplicationContext ac  = new AnnotationConfigApplicationContext(SpringConfig.class);*//*
    UserService cs= (UserService)ac.getBean(UserService.class);*/
    @Autowired
    private UserService userService;
    @RequestMapping("/userLogin")
    public ModelAndView login(User user){
        System.out.println(user);
        ModelAndView modelAndView = new ModelAndView();
        User u = userService.findId(user);
        if (u != null){
            modelAndView.setViewName("index");
        }else {
            modelAndView.setViewName("login1");
        }
        return modelAndView;
    }
}
